# Figure D2: Covid-19 unemployment effects on Asian hate crimes: excluding tourism

rm(list = ls())

setwd('/path/to/replication/')

library(data.table)
library(estimatr)
library(ggplot2)
library(dplyr)

if (!file.exists('./output/out_econ_tourism.RData') &
    !file.exists('./output/out_econ_con_trend_all.RData')) {
  source('./code/figureD2reg.R')
}

load('./output/out_econ_tourism.RData')
load('./output/out_econ_con_trend_all.RData')

out <- rbind(
  tidy(out_econ_con_trend_all) %>% filter(term=='covid_econ') %>% select(estimate, conf.low, conf.high),
  tidy(out_econ_tourism_con_trend_all) %>% filter(term=='covid_econ_tourism') %>% select(estimate, conf.low, conf.high)
)

types <- data.frame(treat = c('main measure', 'without tourism'))

out <- cbind(out,types)

out %>% ggplot() + aes(x = treat, y = estimate) +
  geom_point() +
  geom_hline(yintercept = 0, colour='#999999', linetype='longdash') + 
  geom_linerange(aes(ymin = conf.low, ymax = conf.high)) +
  theme(
    legend.position="bottom", legend.title = element_blank(), legend.text = element_text(size = 12),
    panel.grid.major = element_blank(),
    panel.grid.minor = element_blank(),
    panel.background = element_blank(), axis.line = element_line(colour = "black"
    ),axis.title.y = element_text(size = rel(1.2)), axis.text.x=element_text(size=14),axis.text.y=element_text(size=12)) +
  xlab(NULL) +
  ylab('Unemployment effects of Covid-19 on hate crimes')
ggsave('./unemployment_effects_without_tourism.pdf', width=6, height=4.85)